﻿using PetaPoco;
using PmSoft;
using PmSoft.Caching;
using System.ComponentModel;
using static Modules.Project.ProjectConstants;

namespace Modules.System.Role
{
    /// <summary>
    /// 系统角色表
    ///</summary>
    [TableName("sys_role")]
    [Description("角色表")]
    [PrimaryKey("role_id", AutoIncrement = true)]
    [CacheSetting(true)]
    [Serializable]
    public class SysRole : IDelEntity
    {
        /// <summary>
        /// 主键
        ///</summary>
        [Column("role_id")]
        public int RoleId { get; set; }

        /// <summary>
        /// 角色名称
        ///</summary>
        [Column("name")]
        public string Name { get; set; }

        /// <summary>
        /// 角色编码
        ///</summary>
        [Column("code")]
        public string Code { get; set; }
        /// <summary>
        /// 行业分类
        /// </summary>
        [Column("industry_type")]
        public 行业主管部门? IndustryType { get; set; }

        /// <summary>
        /// 显示顺序
        ///</summary>
        [Column("sort")]
        public int? Sort { get; set; }

        /// <summary>
        /// 角色状态(1-正常；0-停用)
        ///</summary>
        [Column("status")]
        public RoleStatus Status { get; set; } = RoleStatus.Normal;

        /// <summary>
        /// 逻辑删除标识(0-未删除；1-已删除)
        ///</summary>
        [Column("is_deleted")]
        public bool IsDeleted { get; set; }

        /// <summary>
        /// 创建时间
        ///</summary>
        [Column("create_time")]
        public DateTime? CreateTime { get; set; }

        /// <summary>
        /// 更新时间
        ///</summary>
        [Column("update_time")]
        public DateTime? UpdateTime { get; set; }

        #region IEntity 成员

        [Ignore]
        object IEntity.EntityId { get { return RoleId; } }

        [Ignore]
        bool IDelEntity.IsDeletedInDatabase { get => IsDeleted; set => IsDeleted = value; }

        #endregion IEntity 成员
    }
}